<?php
	/**
	* Products Delete
	* 
	* @author trungdt
	* @since Sep 27, 2011
	*/
	if (!defined('EXPONENT')) exit('');

	$product = null;
	if (isset($_POST['id'])) {
		$product = $db->selectObject('productsmodule_products','id='.intval($_POST['id']));
		if ($product) {
			$loc = unserialize($product->location_data);
		}
	}

	$obj=null;
	$obj->success=1;
	$obj->id=0;
	if ($product) {
		$obj->id=$product->id;
		if (exponent_permissions_check(array('administrate',"configure", "delete"),$loc)) {
			$db->delete('productsmodule_products','id='.$product->id);
			$obj->id=$product->id;
		} else {
			//echo SITE_403_HTML;
			$obj->success=0;
		}
	} else {
		//echo SITE_404_HTML;
		$obj->success=0;
	}

	echo json_encode($obj);
?>
